package com.hmall.search.web;

import com.hmall.search.pojo.Item;
import com.hmall.search.pojo.ItemDoc;
import com.hmall.search.pojo.PageDTO;
import com.hmall.search.pojo.ResultParam;
import com.hmall.search.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 *
 */
@RestController
@RequestMapping("/search")
public class SearchController {

    @Autowired
    private SearchService searchService;

    //布尔查询
    @PostMapping("/list")
    public PageDTO list(@RequestBody ResultParam param){
        PageDTO pageDTO = searchService.getList(param);
        return pageDTO;
    }
    //自动补全
    @GetMapping("/suggestion")
    public List<String> suggestion(String key){
        List<String> list = searchService.suggestion(key);
       return list;
    }
    //聚合搜索
    @PostMapping("/filters")
    public Map<String, List<String>> filters(@RequestBody ResultParam resultParam){
       Map<String,List<String>> map = searchService.filters(resultParam);
        return map;
    }

}
